<template>
  <div>
    <!-- <p>id: {{id}}</p> -->
    <div class="ni" v-for="(item, index) in newsInfo" :key="index">
      <div class="ni-h">
        <p>{{item.title}}</p>
        <p>发表时间：{{item.add_time | dateFormat}}</p>
        <span>点击{{item.click}}次</span>
      </div>
      <p v-html="item.content"></p>
    </div>

    <!-- 评论区域 -->
    <commentBox :cmid="this.id"> </commentBox>
  </div>
</template>

<script>
import comment from '../subcomponent/comment.vue'
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsInfo: []
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.$http.get("api/getnew/" + this.id).then(result => {
        if (result.body.status == 0) {
          this.newsInfo = result.body.message;
        }
      });
    }
  },
  components: {
    "commentBox": comment
  }
};
</script>
<style lang="less" scoped>
</style>
